package com.eling.elcms.travel.model;

import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.model.BaseModel;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;

import javax.persistence.*;

/**
 * 人员结算金额信息
 * 
 * @author wen
 *
 */
@Entity
@Table(name = "travel_checkoutsettlement")
@Indexed
public class CheckOutSettlement extends BaseModel {

	private static final long serialVersionUID = 3138040115425983565L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	@In
	private Long pkCheckOutSettlement;

	/** 住宿 */
	@Field
	@Column
	private Double room;

	/** 节假日 */
	@Field
	@Column
	private Double holiday;

	/** 电费 */
	@Field
	@Column
	private Double electric;

	/** 电费其他 */
	@Field
	@Column
	private Double electricOther;

	/** 冷水费 */
	@Field
	@Column
	private Double coldWater;

	/** 热水费 */
	@Field
	@Column
	private Double hotWater;

	/** 水费其他 */
	@Field
	@Column
	private Double waterOther;

	/** 电话费 */
	@Field
	@Column
	private Double telephone;

	/** 餐饮 */
	@Field
	@Column
	private Double food;

	/** 餐饮其他 */
	@Field
	@Column
	//TODO 无用业务，待删除
	private Double foodOther;

	/** 康乐 */
	@Field
	@Column
	private Double health;

	/** 康乐其他 */
	@Field
	@Column
	private Double healthOther;

	/** 交通 */
	@Field
	@Column
	private Double traffic;

	/** 接送 */
	@Field
	@Column
	private Double pickUp;

	/** 组团管理 */
	@Field
	@Column
	private Double manager;

	/** 其他 */
	@Field
	@Column
	private Double other;

	/** 费用合计 */
	@Field
	@Column
	private Double sum;

	/** 权证抵扣 */
	@Field
	@Column
	private Double expense;

	/** 床位抵扣 */
	@Field
	@Column
	private Double bedSubsidy;

	/** 床位抵扣(扣除单位) */
	@Field
	@Column
	private Double bedSubsidyUnit;

	/** 福利抵扣 */
	@Field
	@Column
	private Double coupon;

	/** 结算完成 */
	@Field
	@Column
	private Boolean checkOutSettlement;

	/** 结算余额 */
	@Field
	@Column
	private Double balance;

	/** 备注 */
	@Field
	@Column
	private String remak;

	/** 护理费 */
	@Field
	@Column
	private Double nurse;

	/** 物业费 */
	@Field
	@Column
	private Double property;

	@Version
	private Integer version;

	public Long getPkCheckOutSettlement() {
		return pkCheckOutSettlement;
	}

	public void setPkCheckOutSettlement(Long pkCheckOutSettlement) {
		this.pkCheckOutSettlement = pkCheckOutSettlement;
	}

	public Double getRoom() {
		return room;
	}

	public void setRoom(Double room) {
		this.room = room;
	}

	public Double getElectric() {
		return electric;
	}

	public void setElectric(Double electric) {
		this.electric = electric;
	}

	public Double getColdWater() {
		return coldWater;
	}

	public void setColdWater(Double coldWater) {
		this.coldWater = coldWater;
	}

	public Double getHotWater() {
		return hotWater;
	}

	public void setHotWater(Double hotWater) {
		this.hotWater = hotWater;
	}

	public Double getTelephone() {
		return telephone;
	}

	public void setTelephone(Double telephone) {
		this.telephone = telephone;
	}

	public Double getFood() {
		return food;
	}

	public void setFood(Double food) {
		this.food = food;
	}

	public Double getHealth() {
		return health;
	}

	public void setHealth(Double health) {
		this.health = health;
	}

	public Double getTraffic() {
		return traffic;
	}

	public void setTraffic(Double traffic) {
		this.traffic = traffic;
	}

	public Double getPickUp() {
		return pickUp;
	}

	public void setPickUp(Double pickUp) {
		this.pickUp = pickUp;
	}

	public Double getManager() {
		return manager;
	}

	public void setManager(Double manager) {
		this.manager = manager;
	}

	public Double getOther() {
		return other;
	}

	public void setOther(Double other) {
		this.other = other;
	}

	public Double getSum() {
		Double calSum = 0.0;
		calSum += convertToDouble(coldWater) + convertToDouble(electric) + convertToDouble(food)
				+ convertToDouble(foodOther) + convertToDouble(health) + convertToDouble(healthOther)
				+ convertToDouble(holiday) + convertToDouble(hotWater) + convertToDouble(manager)
				+ convertToDouble(nurse) + convertToDouble(other) + convertToDouble(pickUp) + convertToDouble(property)
				+ convertToDouble(room) + convertToDouble(telephone) + convertToDouble(traffic)
				+ convertToDouble(electricOther);
		return calSum;
	}

	public void setSum(Double sum) {
		this.sum = sum;
	}

	public Double getExpense() {
		return expense;
	}

	public void setExpense(Double expense) {
		this.expense = expense;
	}

	public Double getBedSubsidy() {
		return bedSubsidy;
	}

	public void setBedSubsidy(Double bedSubsidy) {
		this.bedSubsidy = bedSubsidy;
	}

	public Double getCoupon() {
		return coupon;
	}

	public void setCoupon(Double coupon) {
		this.coupon = coupon;
	}

	public Double getBalance() {
		Double calCalance = 0.0;
		calCalance += convertToDouble(bedSubsidy) + convertToDouble(coupon) + convertToDouble(expense);
		calCalance = this.getSum() - calCalance;
		return calCalance;
	}

	public void setBalance(Double balance) {
		this.balance = balance;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Boolean getCheckOutSettlement() {
		return checkOutSettlement;
	}

	public void setCheckOutSettlement(Boolean checkOutSettlement) {
		this.checkOutSettlement = checkOutSettlement;
	}

	public Double getHoliday() {
		return holiday;
	}

	public void setHoliday(Double holiday) {
		this.holiday = holiday;
	}

	public String getRemak() {
		return remak;
	}

	public void setRemak(String remak) {
		this.remak = remak;
	}

	public Double getElectricOther() {
		return electricOther;
	}

	public void setElectricOther(Double electricOther) {
		this.electricOther = electricOther;
	}

	public Double getWaterOther() {
		return waterOther;
	}

	public void setWaterOther(Double waterOther) {
		this.waterOther = waterOther;
	}

	public Double getFoodOther() {
		return foodOther;
	}

	public void setFoodOther(Double foodOther) {
		this.foodOther = foodOther;
	}

	public Double getHealthOther() {
		return healthOther;
	}

	public void setHealthOther(Double healthOther) {
		this.healthOther = healthOther;
	}

	public Double getNurse() {
		return nurse;
	}

	public void setNurse(Double nurse) {
		this.nurse = nurse;
	}

	public Double getProperty() {
		return property;
	}

	public void setProperty(Double property) {
		this.property = property;
	}

	public Double getBedSubsidyUnit() {
		return bedSubsidyUnit;
	}

	public void setBedSubsidyUnit(Double bedSubsidyUnit) {
		this.bedSubsidyUnit = bedSubsidyUnit;
	}

	public Double convertToDouble(Double d) {
		if (d == null) {
			return 0.0;
		} else {
			return d;
		}
	}
}
